package com.spn.blog.api.controller.system;

import com.spn.blog.common.vo.Result;
import com.spn.blog.common.vo.params.TpuserBindParam;
import com.spn.blog.service.login.OtherLogin;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Api(tags = "社交登录模块")
@Controller
@RequestMapping()
public class AccessTokenController {

    @DubboReference(check = false)
    private OtherLogin otherLogin;

    /**
     *
     * @param code 授权码
     * @param state
     * @return
     */
    @ApiOperation(value = "第三方Gitee登录接口")
    @GetMapping("api/callback")
    public String callback(@RequestParam(name = "code") String code, @RequestParam(name = "state") String state) {
        return otherLogin.callback(code, state);
    }



    @PostMapping("api/userbind")
    @ResponseBody
    public Result userbind(@RequestBody TpuserBindParam tpuserBindParam){
        return otherLogin.userbind(tpuserBindParam);
    }

    @PostMapping("api/secondlogin")
    @ResponseBody
    public Result secondlogin(@RequestBody TpuserBindParam tpuserBindParam) {
        return otherLogin.secondlogin(tpuserBindParam);
    }

}